#include	<windows.h>
#include	<time.h>

//out 
#include	"TimeCRV.h"

#include	"..\..\..\lib\vmpsdk\1.6\VMProtectSDK.h"

#pragma optimize( "g", off )

BOOL	WINAPI	GetAbortDate(IN  DWORD		dw_time,
			     OUT PSYSTEMTIME	sysTime)
	{
	time_t	o_time;

	struct tm *tblock = NULL;

	ZeroMemory(sysTime,sizeof(SYSTEMTIME));

	VMProtectBegin

	o_time = dw_time;
	if ( (tblock = localtime(&o_time)) == NULL )
		return FALSE;
	
	sysTime->wYear = LOWORD((tblock->tm_year)+1900);
	sysTime->wMonth = LOWORD(tblock->tm_mon + 1 );
	sysTime->wDay = LOWORD(tblock->tm_mday);
	sysTime->wHour = LOWORD(tblock->tm_hour);
	sysTime->wMinute = LOWORD(tblock->tm_min);
	sysTime->wSecond = LOWORD(tblock->tm_sec);
	sysTime->wDayOfWeek = LOWORD(tblock->tm_wday);

	return TRUE;
	VMProtectEnd
	}

BOOL	WINAPI	GetAbortTimet(
			      OUT  DWORD	*dw_time,
			      IN   PSYSTEMTIME	sysTime)
	{
	
	struct tm tblock;

	memset(&tblock,0,sizeof(tblock));
	
	VMProtectBegin

	if (dw_time != NULL )
		{
		tblock.tm_year = sysTime->wYear -1900 ;
		tblock.tm_mon  = sysTime->wMonth - 1;
		tblock.tm_mday = sysTime->wDay ;
		tblock.tm_hour = sysTime->wHour ;
		tblock.tm_min  = sysTime->wMinute ;
		tblock.tm_sec  = sysTime->wSecond ;
		tblock.tm_wday = sysTime->wDayOfWeek ;

		*dw_time = mktime(&tblock) ;
		return TRUE;
		}
	else
		
		{
		return FALSE;
		}
	VMProtectEnd
	}

VOID	WINAPI	CoverTmToSystemtime(IN struct tm *psttm,OUT PSYSTEMTIME sysTime)
	{
	VMProtectBegin
	sysTime->wYear = LOWORD((psttm->tm_year)+1900);
	sysTime->wMonth = LOWORD(psttm->tm_mon + 1 );
	sysTime->wDay = LOWORD(psttm->tm_mday);
	sysTime->wHour = LOWORD(psttm->tm_hour);
	sysTime->wMinute = LOWORD(psttm->tm_min);
	sysTime->wSecond = LOWORD(psttm->tm_sec);
	sysTime->wDayOfWeek = LOWORD(psttm->tm_wday);
	return;
	VMProtectEnd
	}
#pragma optimize( "g", on )